package com.cv.platform.controller.platform.history;

import com.cv.framework.common.pojo.PageResult;
import com.cv.framework.common.pojo.Result;
import com.cv.platform.controller.platform.history.vo.CvVideoDetailHistoryRespVO;
import com.cv.platform.controller.platform.history.vo.CvVideoHistoryRespVO;
import com.cv.platform.controller.platform.history.vo.CvVideoHistorySaveReqVO;
import com.cv.platform.controller.platform.history.vo.CvVideoHistoryReqVO;
import com.cv.platform.service.history.CvVideoHistoryRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 视频平台 - 视频播放历史记录控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 视频播放历史记录控制层")
@RestController
@RequestMapping("/platform/video/history")
public class CvVideoHistoryController {

    @Resource
    private CvVideoHistoryRecordService cvVideoHistoryRecordService;

    @GetMapping("detail")
    @Operation(summary = "获取视频播放历史记录")
    public Result<CvVideoDetailHistoryRespVO> getVideoHistory(Long videoId) {
        return Result.success(cvVideoHistoryRecordService.getVideoHistoryRecord(videoId));
    }

    @PostMapping("save")
    @Operation(summary = "保存视频播放历史记录")
    public Result<Void> saveVideoHistory(@RequestBody CvVideoHistorySaveReqVO reqVO) {
        cvVideoHistoryRecordService.saveVideoHistoryRecord(reqVO);
        return Result.success();
    }

    @DeleteMapping("delete")
    @Operation(summary = "删除视频播放历史记录")
    public Result<Void> deleteVideoHistory(Long videoId) {
        cvVideoHistoryRecordService.deleteVideoHistoryRecord(videoId);
        return Result.success();
    }

    @DeleteMapping("clear")
    @Operation(summary = "清空视频播放历史记录")
    public Result<Void> clearVideoHistory() {
        cvVideoHistoryRecordService.clearVideoHistoryRecord();
        return Result.success();
    }

    @GetMapping("page")
    @Operation(summary = "分页查询视频播放历史记录")
    public Result<PageResult<CvVideoHistoryRespVO>> getVideoHistoryPage(CvVideoHistoryReqVO reqVO) {
        return Result.success(cvVideoHistoryRecordService.getVideoHistoryRecordPage(reqVO));
    }

}
